﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UserControlCadCategoria.ascx.cs" Inherits="TrabalhoWeb.UserControlCadCategoria" %>
<style type="text/css">
    .cad 
    {
        float:left;
        background-color:lightgrey;
    }
    .lista2
    {
        float:right;
        height: 218px;
    }
    
</style>
<div class ="cad">
    <table>
        <tr>
            <td>
                <asp:Label runat="server" Text="Id"/>
            </td>
            <td>
                <asp:Label ID="lblId" runat="server" Text="0"/>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label runat="server"  Text="Nome"/>
            </td>
            <td>
                <asp:TextBox ID="txtNome" runat="server" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                ControlToValidate="txtNome" 
                ErrorMessage="O campo nome é obrigatório!" ValidationGroup="Cadastro">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label runat="server" Text="Descrição"/>
            </td>
            <td>
                <asp:TextBox ID="txaDescricao" runat="server"/>
            </td>
        </tr>        
        <tr>
            <td></td>
            <td>
                <asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red" 
                ValidationGroup="Cadastro" />
            </td>
            <td>
                <asp:Button ID="btnSalvar" runat="server" OnClick="btnSalvar_Click" Text ="Salvar" 
                    ValidationGroup="Cadastro"/>                
            </td>
        </tr>
        <tr>
            <td>
                <div class="lista2">
                    
                    <asp:GridView ID="grvCategorias" runat="server" AutoGenerateColumns="False" 
                        OnRowCommand="grvCategorias_RowCommand">
                        <Columns>            
            
                            <asp:BoundField DataField="ID" HeaderText="Id" SortExpression="ID"/>
                            <asp:BoundField DataField="NOME" HeaderText="Nome"  SortExpression="NOME"/>
                            <asp:BoundField DataField="DESCRICAO" HeaderText="Descrição" SortExpression="DESCRICAO"/>            
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:ImageButton
                                    runat = "server"
                                    imageUrl = "~/IMG/iconeExcluir.gif" 
                                    CommandName = "excluir"
                                    OnClientClick = "return confirm('Deseja excluir o categoria?');"
                                    CommandArgument='<%#Eval("ID") %>'                    
                                    />
                                    <asp:ImageButton
                                    runat = "server"
                                    imageUrl = "~/IMG/editar.gif" 
                                    CommandName = "editar"
                                    CommandArgument='<%#Eval("ID") %>'                    
                                    />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                            
                </div>
            </td>
        </tr>
    </table>

</div>
